home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
AOL File Library: 2,801 to 2,900
/
aol-file-protocol-4400-2801-to-2900.zip
/
AOLDLs
/
C++ Files Library
/
UVisualEffect (PP)
/
UVisualEffect.sit
/
UVisualEffect
/
UVisualEffect.cp
< prev
next >
Wrap
Text File
|
1995-08-23
|
6KB
|
209 lines
// ===========================================================================
// UVisualEffect.cp ⌐ 1995, âric Forget. All rights reserved.
// ===========================================================================
//
// ************************************************************************
// * *
// * Before using this code you should read the "License Agreement" *
// * document and agree with it. *
// * *
// ************************************************************************
//
// UVisualEffect help you doing the "visual effect" like in the Finder
// when you open or close a file/folder.
//
// ---------------------------------------------------------------------------
// Instructions Notes:
// ------------------
//
// There is two methods:
//
// 1) (a) Call one of the two SetFirstXXX() method
// (b) Call one of the two SetLastXXX() method
// (c) Call DoPlayEffects()
// Note that XXX should not necessary be the same for both (a) and (b)
//
// 2) (a) Call either SetRects() or SetPanes()
// (b) Call DoPlayEffects()
//
// ---------------------------------------------------------------------------
#include "UVisualEffect.h"
// ---------------------------------------------------------------------------
// Ñ Constantes
// ---------------------------------------------------------------------------
const Rect Rect_Undefined = { -1, -1, -1, -1 };
// ---------------------------------------------------------------------------
// Ñ Initialisation
// ---------------------------------------------------------------------------
Int16 UVisualEffect::sNbrStep = 4;
Rect UVisualEffect::sFirstRect = Rect_Undefined;
Rect UVisualEffect::sLastRect = Rect_Undefined;
// ---------------------------------------------------------------------------
// Ñ Initialize
// ---------------------------------------------------------------------------
void
UVisualEffect::Initialize(
Int16 inNbrStep)
{
sNbrStep = inNbrStep;
sFirstRect = Rect_Undefined;
sLastRect = Rect_Undefined;
}
// ---------------------------------------------------------------------------
// Ñ SetFirstRect
// ---------------------------------------------------------------------------
void
UVisualEffect::SetFirstRect(
Rect inFirstRect)
{
sFirstRect = inFirstRect;
}
// ---------------------------------------------------------------------------
// Ñ SetFirstPane
// ---------------------------------------------------------------------------
void
UVisualEffect::SetFirstPane(
LPane *inFirstPane)
{
SetFirstRect(CalcGlobalPaneFrame(inFirstPane));
}
// ---------------------------------------------------------------------------
// Ñ SetLastRect
// ---------------------------------------------------------------------------
void
UVisualEffect::SetLastRect(
Rect inLastRect)
{
sLastRect = inLastRect;
}
// ---------------------------------------------------------------------------
// Ñ SetLastPane
// ---------------------------------------------------------------------------
void
UVisualEffect::SetLastPane(
LPane *inLastPane)
{
SetLastRect(CalcGlobalPaneFrame(inLastPane));
}
// ---------------------------------------------------------------------------
// Ñ SetRects
// ---------------------------------------------------------------------------
void
UVisualEffect::SetRects(
Rect inFirstRect,
Rect inLastRect)
{
SetFirstRect(inFirstRect);
SetLastRect(inLastRect);
}
// ---------------------------------------------------------------------------
// Ñ SetPanes
// ---------------------------------------------------------------------------
void
UVisualEffect::SetPanes(
LPane *inFirstPane,
LPane *inLastPane)
{
SetFirstPane(inFirstPane);
SetLastPane(inLastPane);
}
// ---------------------------------------------------------------------------
// Ñ CalcGlobalPaneFrame
// ---------------------------------------------------------------------------
Rect
UVisualEffect::CalcGlobalPaneFrame(
LPane *inPane)
{
Rect frame;
inPane->CalcPortFrameRect(frame);
inPane->PortToGlobalPoint(topLeft(frame));
inPane->PortToGlobalPoint(botRight(frame));
return frame;
}
// ---------------------------------------------------------------------------
// Ñ DoPlayEffects
// ---------------------------------------------------------------------------
void
UVisualEffect::DoPlayEffects()
{
if (!::EqualRect(&sFirstRect, &Rect_Undefined) &&
!::EqualRect(&sLastRect, &Rect_Undefined)) {
GrafPtr theScreen = UScreenPort::GetScreenPort();
Int32 finalTick;
Rect stepRect, tempRect;
LView::OutOfFocus(nil);
SetPort(theScreen);
stepRect.top = (sLastRect.top - sFirstRect.top ) / (sNbrStep + 2);
stepRect.left = (sLastRect.left - sFirstRect.left ) / (sNbrStep + 2);
stepRect.bottom = (sLastRect.bottom - sFirstRect.bottom) / (sNbrStep + 2);
stepRect.right = (sLastRect.right - sFirstRect.right ) / (sNbrStep + 2);
::PenPat(&UQDGlobals::GetQDGlobals()->gray);
::PenMode (patXor);
for(Int16 j = 0; j < 2; j++) {
tempRect = sFirstRect;
for(Int16 i = 0; i < (sNbrStep + 2); i++) {
::FrameRect(&tempRect);
::Delay(1, &finalTick);
tempRect.top += stepRect.top;
tempRect.left += stepRect.left;
tempRect.bottom += stepRect.bottom;
tempRect.right += stepRect.right;
}
::Delay(4, &finalTick);
}
}
// Reset initial value
Initialize();
}